Skip to content

fix(platform): reserve a quarter of the Ps for the default loop count (refs #756) - #1306

Draft
FumingPower3925 wants to merge 1 commit into
mainfrom
fix/756-loop-reserve-n4
Draft

FumingPower3925 wants to merge 1 commit into
mainfrom
fix/756-loop-reserve-n4

Conversation

@FumingPower3925

@FumingPower3925 FumingPower3925 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Refs #756.

What

The default loop count (Config.Workers not set, a host of alike CPUs) leaves a reserve of Ps to the goroutines that are not loops. The reserve was max(1, n/8) (14 loops of 16). This raises it to max(1, n/4) (none for n <= 2): 12 of 16, 6 of 8, 3 of 4, 24 of 32. A Workers set by the user and the big.LITTLE plan are unchanged.

Files: internal/platform/cpuplan_linux.go (the one return statement and its comment), config.go and internal/resource/resource.go (docs), README.md, and the pinned figures in the tests.

Why

Cluster comparison on one amd64 host (16 CPUs, WebSocket large-echo, p99 against the std-h1 control, 5 repetitions per arm). MEASURED, lane-finding, not closing, on celeris 8ef98b7 (levels are fractions of saturation):

arm 0.5 0.75
default, 14 loops on 16 Ps 3.26 8.75
12 loops on 16 Ps (this change) 1.45 3.37
14 loops, GOMAXPROCS 20 1.46 3.78

The Ps left free decide the tail. The bar of #756 is a ratio of at most 3 (near-miss up to 3.5) at 0.25, 0.5 and 0.75: this change alone is at the near-miss at 0.75, so it does not claim to close #756.

Status: NOT TO BE MERGED YET

Draft. It must not merge until a RULE 74 A/B with an A/A twin shows no small-message throughput or tail regression (HTTP/1 sync and async, io_uring, adaptive) AND no regression in the driver cells: fewer default loops also lowers what scales with NumWorkers() (the server-wide MaxConns, driver pools such as PostgreSQL at 4xNumWorkers(): 56 to 48 on 16 CPUs), so the A/B includes the pg and redis cells, and the closing runs on the final commit are done.

Tests

gofmt clean on the changed files (gofmt -l . also lists test/benchcmp_ws/bench_test.go, which this diff does not touch) and go vet clean; linux/arm64 and linux/amd64 builds; go test -race of internal/platform and internal/resource; the full internal/engine/epoll and internal/adaptive packages (docker, seccomp unconfined, memlock 8 MiB); the pinned-figure tests of the reserve pass.

…fault loop count (refs #756)

The default loop count (Config.Workers not set, a host of alike CPUs) was
n - max(1, n/8): 14 of 16. A cluster comparison on one amd64 host (WebSocket
large-echo p99 against the std engine, 5 repetitions per arm, the rated
levels 0.5 and 0.75 of saturation) found that the Ps left free decide the
tail: 14 loops on 16 Ps read 3.26 and 8.75 times, 12 loops 1.45 and 3.37
times (MEASURED, lane-finding, not closing).

The reserve is n - max(1, n/4), none for n <= 2: 12 of 16, 6 of 8, 3 of 4.
A Workers set by the user is unchanged and so is the big.LITTLE plan.
Updates the defaultLoopReserve comment, the Config.Workers and Resources
docs, the README and the pinned figures in the tests.

Not to be merged before the A/B with an A/A twin shows no small-message
throughput regression.
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant